package com.example;

import java.io.IOException;

import com.example.entity.Person;


import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;


@WebServlet("/home")
public class Home extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 向浏览器响应
        req.setAttribute("name", "Alan");

        Person person =new Person(1,"Alan",12,"aasd@email.com");
        req.setAttribute("person", person);

        RequestDispatcher disp = req.getRequestDispatcher("/WEB-INF/jsp/home.jsp");
        disp.forward(req, resp);
        person.getName();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
        
    }

    
}
